<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>errcatch</title>
  </head>
  <body bgcolor="#FFFFFF">
    <center>Scilab Function</center>
    <div align="right">Last update : 30/08/2005</div>
    <p>
      <b>errcatch</b> -  error trapping</p>
    <h3>
      <font color="blue">Calling Sequence</font>
    </h3>
    <dl>
      <dd>
        <tt>errcatch(n [,'action'] [,'option'])   </tt>
      </dd>
      <dd>
        <tt>errcatch()   </tt>
      </dd>
    </dl>
    <h3>
      <font color="blue">Parameters</font>
    </h3>
    <ul>
      <li>
        <tt>
          <b>n</b>
        </tt>: integer</li>
      <li>
        <tt>
          <b>action, option</b>
        </tt>: strings</li>
    </ul>
    <h3>
      <font color="blue">Description</font>
    </h3>
    <p>
      <tt>
        <b>errcatch</b>
      </tt> gives an "action" (error-handler)  to be 
    performed when an error of type <tt>
        <b>n</b>
      </tt> occurs.
    <tt>
        <b>n</b>
      </tt> has the following meaning:
  </p>
    <p>
    if <tt>
        <b>n&gt;0</b>
      </tt>, <tt>
        <b>n</b>
      </tt> is the error number to trap
  </p>
    <p>
    if <tt>
        <b>n&lt;0</b>
      </tt>  all errors are to be trapped
  </p>
    <p>
      <tt>
        <b>action</b>
      </tt> is one of the following character strings:
  </p>
    <dl>
      <dd>
        <b>"pause"</b>: a pause is executed when trapping the error. This option is useful for debugging purposes. Use <tt>
          <b>whereami()</b>
        </tt> to get informations on the current context.</dd>
      <dd>
        <b>"continue"</b>: next instruction in the function or exec files is executed, current instruction is ignored. It is possible to check if an error has occured using the <tt>
          <b>iserror</b>
        </tt> function. Do not forget to clear the error using the <tt>
          <b>errclear</b>
        </tt> function as soon as possible  This option is useful for error recovery. In many cases, usage of <tt>
          <b> errcatch(n,"continue",..)</b>
        </tt> can be replaced by the use of <tt>
          <b>execstr</b>
        </tt> function.</dd>
      <dd>
        <b>"kill"</b>: default mode, all intermediate functions are killed, scilab goes back to the level 0 prompt.</dd>
      <dd>
        <b>"stop"</b>: interrupts the current Scilab session (useful when  Scilab is called from an external program).</dd>
    </dl>
    <p>
      <tt>
        <b>option</b>
      </tt> is the character string <tt>
        <b>'nomessage'</b>
      </tt> for killing
    error message.</p>
    <p>
    To set back default mode, enter <tt>
        <b>errcatch(-1,"kill")</b>
      </tt> or similarly
    <tt>
        <b>errcatch(-1)</b>
      </tt>.</p>
    <p>
    Then called in a scilab function the <tt>
        <b>errcatch</b>
      </tt> is automatically
    reset to the default mode when the function returns.</p>
    <p>
      <tt>
        <b>errcatch()</b>
      </tt> is an obsolete equivalent of <tt>
        <b>errcatch(-1)</b>
      </tt>.</p>
    <h3>
      <font color="blue">Remark</font>
    </h3>
    <dl>
      <p>
        <tt>
          <b>errcatch</b>
        </tt> is obsolete. 
 Use <a href="try.htm">
          <tt>
            <b>try</b>
          </tt>
        </a> or <tt>
          <b>execstr(...,'errcatch')</b>
        </tt>  instead of <tt>
          <b>errcatch</b>
        </tt> when
 possible.</p>
    </dl>
    <h3>
      <font color="blue">See Also</font>
    </h3>
    <p>
      <a href="try.htm">
        <tt>
          <b>try</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="errclear.htm">
        <tt>
          <b>errclear</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="iserror.htm">
        <tt>
          <b>iserror</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="whereami.htm">
        <tt>
          <b>whereami</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="execstr.htm">
        <tt>
          <b>execstr</b>
        </tt>
      </a>,&nbsp;&nbsp;</p>
  </body>
</html>
